-
-
Notifications
You must be signed in to change notification settings - Fork 330
Introduce multi-period Account data type and use it for MultiBalanceReport and BudgetReport. #2360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d8d6312
to
04cb729
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Initial comments.
hledger/test/balance/balance.test
Outdated
|
||
# ** 16. balance --flat --empty does not display accounts which have not been | ||
# seen, even if they're implied, but does show accounts that have been seen | ||
# with 0 balance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what this means in userese ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It means that if there have never been any postings to assets
, then we shouldn't display a value for the assets
account, even with --empty
. On the other hand, we should show assets:bank:checking
, since there have been postings to that account.
This was the case before, but turned out to be a non-trivial thing to maintain in the refactoring, so I added a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the test description. Let me know if it's clearer.
@@ -50,7 +50,6 @@ Budget performance in 2016-12-01..2016-12-03: | |||
|| 2016-12-01 2016-12-02 2016-12-03 | |||
==================++============================================================== | |||
assets:cash || $-10 [ 40% of $-25] $-14 [56% of $-25] $-51 [204% of $-25] | |||
expenses || $10 [ 40% of $25] $14 [56% of $25] $51 [204% of $25] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another behaviour change, worth noting with a ! in message.
The parent "expenses" account is not shown, because there's no explicit budget goal for it, and because we're in list mode ? So if we want to see aggregated budget performance, tree mode will be needed. Ok I guess.
Why is it still shown in the previous test ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me look into this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the reason is as follows:
Unless called with -E
, then a budget report will count any unbudgeted subaccounts against their earliest budgeted parent. So both expenses:cab
and expenses:movies
are rolled up to expenses
. Even though expenses
doesn't have a budget itself, it gets the sum of the budgets of its subaccounts.
I'm not sure how I feel about this behaviour, but I think changing it is out of scope for this PR.
Could we quantify that a little more - eg "balance reports are 1% faster with 1k txns, 5% faster with 10k txns" ? |
Also I wonder if there's any memory impact, |
Rephrase everything in terms of boringness to make for a clearer logical flow.
This removes the type alias Account, and replaces it with the fully-qualified name Account AccountBalance. This breaks some backwards compatibility, but that was already broken by the change of Account type constructor in any case. This simplifies the interface.
Rename applyAccountBalance to mapAccountBalance.
mergeWithKey can create corrupt output if its inputs don't satisfy certain conditions. We restrict the domain here to only those cases where it is guaranteed safe. This still covers all the cases that we need.
This keeps Hledger.Data.AccountBalance and Hledger.Data.AccountBalances separate.
If a report would have an empty interval span, which occurs when the journal is empty, then instead of an empty list, return a singleton containing the entire report span.
Sorry for the delay. I've rebased against master and pushed a quick fix for the failing test. I think there's a better fix involving a bit more work, but I want to avoid making this PR heavier than it already is. I've been a bit busy, so haven't yet had the chance to create a separate squashed PR. Please let me know if you still feel that's valuable and I'll try to devote time to it when I can. Those doc tweaks look good to me. I'll incorporate them as a separate commit rather than rebasing, if you don't mind. |
Thanks for the updates. I don't mind doing an unsquashed merge if it saves time. We are close to (ideal) release date. I don't want to cause more delay, but prudence would probably say merge this after release so we have more time to flush out surprises. On the other hand it's passing tests. I could probably go either way, do you have a preference ? |
Yes, definitely wait. I'm in no hurry, and some extra time for testing would be appropriate for a refactoring of the core code like this. |
I've renamed the data constructors and their record names according to your suggestions above. The one exception is I chose one of your alternative names |
Goals: - Use names and descriptions matching the generality/specificity of the types - Use distinctive names not easily confusable with each other
Thanks! Ok then, we'll merge this after 1.43.
|
This was merged as #2395. |
This rejigs the
MultiBalanceReport
internals to use an enhancedAccount
data type to save the values. This has a few effects:Account
means thatBudgetReport
can be simplified.There are some small changes in behaviour with respect to budget reports, where it looked like some behaviour was implemented to work around needing to get the budget and actuals into the same shape so they could be merged. This is no longer necessary, but may still be desired for other reasons.
Let me know your thoughts.